package com.jindun.paper.export;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public abstract  class ReportContext {
   private List<ContextEntry> entries = new ArrayList<ContextEntry> ();
  
   public void init () {
     this.prepareData(entries);
   }
   public abstract void prepareData(List<ContextEntry> entries);
   public abstract int  getTableRowCount();
   public abstract String getTempFileName();

   
   
   public List<ContextEntry> getEntries() {
      return entries;
   }
   public void setEntries(List<ContextEntry> entries) {
      this.entries = entries;
   }



   public static class ContextEntry  {
      private Map<String, String> variableMap = new HashMap<String, String>();
      private List<Map<String, String>> loopList = new ArrayList<Map<String, String>>();
      public Map<String, String> getVariableMap() {
         return variableMap;
      }
      public void setVariableMap(Map<String, String> variableMap) {
         this.variableMap = variableMap;
      }
      public List<Map<String, String>> getLoopList() {
         return loopList;
      }
      public void setLoopList(List<Map<String, String>> loopList) {
         this.loopList = loopList;
      }
      
      public String getValiableValue(String variableName) {
         return variableMap.get(variableName);
      }
      
      public int getLoopListSize () {
         return loopList.size();
      }
      
      public String getLoopVariableValue (int index, String variableName) {
         if (index >= loopList.size()) {
            return "";
         }
         return loopList.get(index).get(variableName);
      }  
      
   }
   
}
